const App = getApp();
const navigationBarHeight = (getApp().diygwstatusBarHeight + 44) + 'px'
Page({
data: {
          msgs1:[],

},

 //显示提示信息
showModal(message) {
   App.WxService.showModal({
    	title: '友情提示',
    	content: message,
    	showCancel: !1,
   });
},
onShareAppMessage: function () {
},


//页面加载
onLoad(option) {
	if (option){
      this.setData({
         globalOption: option,
		  lname:wx.getStorageSync("lname")
      })
    }
},

onShow(){
    var mid= wx.getStorageSync("uid");

    if (mid=="") {
       this.denglu();
    } else {
        let param = {
            f: 1,
            id: wx.getStorageSync("uid"),
            loadmsg: `正在加载中`
        };


        App.HttpService.getData(param, "/users_List").then(data => { //执行服务器Servlet

            this.setData({

                msgs1: data  //把从服务器端得到的值赋值给数组
            });
        });
    }
},

//页面跳转
navigateTo(e) {
  App.navigateTo(e.currentTarget.dataset.url, e.currentTarget.dataset);
},


    denglu(e)
    {
        this.setData({
            modalName:"Modal"
        })



    },

    login(e)
    {
        var that=this;
        wx.getUserProfile({
            desc:'获取用户相关信息',
            success: res => {
                App.globalData.userInfo = res.userInfo
                console.log(App.globalData.userInfo);

                //调用数据
                let param = {
                    mname:App.globalData.userInfo.nickName,
                    addr:App.globalData.userInfo.avatarUrl
                };

                //调用数据
                App.HttpService.getData(param,"/users_Add").then(data=>{

                    wx.setStorageSync("uid",data[0].jieguo);

                    App.WxService.showToast({
                        title: "登录成功!",
                        icon: 'success',
                        duration: 1500,
                    });
                    setTimeout(function() {

                    }, 1500)

                    that.onShow();
                    this.setData({
                        mid:-1,
                        modalName: null
                    })
                });


            }
        })
    },
})


